package com.chagee.store.operation.api.bo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @author: chang.jiawei
 * @date: 2024/01/16
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class FileBO implements Serializable {

	private static final long serialVersionUID = -1121516683397143369L;
	/**
	 * 文件路径
	 */
	private String filePath;

	/**
	 * 飞书文件code（用于审批）
	 */
	private String larkFileCode;

	/**
	 * 文件名称
	 */
	private String fileName;

	/**
	 * 文件大小，byte
	 */
	private Long size;

	/**
	 * 文件类型
	 */
	private String type;

	public FileBO(String url) {
		new FileBO().setFilePath(url);
	}

	public static List<FileBO> transfer2BO(List<String> urls) {
		return Optional.ofNullable(urls).map(t -> t.stream().map(FileBO::new).collect(Collectors.toList())).orElse(Collections.emptyList());
	}

}
